import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    roles: ['admin','editor']    // 设置该路由进入的权限，支持多个权限叠加
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: '首页',
        meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
      }
    ]
  },
  // 新加入的类别代码
  {
    path: '/courses',
    component: Layout,
    hidden: true,
    name: 'CoursesPage',
    meta: {
      title: '课程管理',
      icon: 'class'
    },
    children: [
      {
        path: 'courseli/index',
        component: () => import('@/views/courses/courseli/index'),
        hidden: true,
        name: 'CoursesCourseliPageList',
        meta: { title: '课程列表', noCache: true }
      },
      {
        path: 'courseli/edit',
        component: () => import('@/views/courses/courseli/edit'),
        hidden: true,
        name: 'CoursesCourseliEdit',
        meta: { title: '课程列表编辑', noCache: true, activeMenu: '/courses/courseli/index' },
        hidden: true
      },
       //新加绑定试卷
      {
        path: 'courseli/bpaper',
        component: () => import('@/views/courses/courseli/bpaper'),
        name: 'CoursesCourseliBpaper',
        meta: { title: '绑定试卷', noCache: true, activeMenu: '/courses/courseli/index' },
        hidden: true
      },
      {
        path: 'videos/index',
        component: () => import('@/views/courses/videos/index'),
        name: 'CoursesVideosPageList',
        meta: { title: '视频列表', noCache: true }
      },
      {
        path: 'videos/edit',
        component: () => import('@/views/courses/videos/edit'),
        name: 'CoursesVideosEdit',
        meta: { title: '视频编辑', noCache: true, activeMenu: '/courses/videos/index' },
        hidden: true
      },
      //新加绑定试卷
      {
        path: 'videos/bpaper',
        component: () => import('@/views/courses/videos/bpaper'),
        name: 'CoursesVideosBpaper',
        meta: { title: '绑定试卷', noCache: true, activeMenu: '/courses/videos/index' },
        hidden: true
      },
      {
        path: 'lecturer/index',
        component: () => import('@/views/courses/lecturer/index'),
        name: 'CoursesLecturerPageList',
        meta: { title: '讲师列表', noCache: true }
      },
      {
        path: 'lecturer/edit',
        component: () => import('@/views/courses/lecturer/edit'),
        name: 'CoursesLecturerEdit',
        meta: { title: '讲师编辑', noCache: true, activeMenu: '/courses/lecturer/index' },
        hidden: true
      }
    ]
  },
  {
    path: '/exam',
    component: Layout,
    hidden: true,
    name: 'ExamPage',
    meta: {
      title: '卷题管理',
      icon: 'exam'
    },
    children: [
      {
        path: 'question/index',
        component: () => import('@/views/exam/question/index'),
        name: 'ExamQuestionPageList',
        meta: { title: '试题管理', noCache: true }
      },
      {
        path: 'question/edit/pinsert',
        component: () => import('@/views/exam/question/edit/pinsert'),
        name: 'pinsertgPage',
        meta: { title: '批量添加试题', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'question/edit/singleChoice',
        component: () => import('@/views/exam/question/edit/single-choice'),
        name: 'singleChoicePage',
        meta: { title: '单选题编辑', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'question/edit/multipleChoice',
        component: () => import('@/views/exam/question/edit/multiple-choice'),
        name: 'multipleChoicePage',
        meta: { title: '多选题编辑', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'question/edit/trueFalse',
        component: () => import('@/views/exam/question/edit/true-false'),
        name: 'trueFalsePage',
        meta: { title: '判断题编辑', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'question/edit/gap-Filling',
        component: () => import('@/views/exam/question/edit/gap-filling'),
        name: 'gapFillingPage',
        meta: { title: '填空题编辑', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'question/edit/shortAnswer',
        component: () => import('@/views/exam/question/edit/short-answer'),
        name: 'shortAnswerPage',
        meta: { title: '简答题编辑', noCache: true, activeMenu: '/exam/question/index' },
        hidden: true
      },
      {
        path: 'paper/index',
        component: () => import('@/views/exam/paper/index'),
        name: 'ExamPaperPageList',
        meta: { title: '试卷管理', noCache: true }
      },
      {
        path: 'paper/edit',
        component: () => import('@/views/exam/paper/edit'),
        name: 'ExamPaperEdit',
        meta: { title: '试卷编辑', noCache: true, activeMenu: '/exam/paper/index' },
        hidden: true
      }
    ]
  },
  {
    path: '/class',
    component: Layout,
    hidden: true,
    name: 'ClassPage',
    meta: {
      title: '班级管理',
      icon: 'class'
    },
    alwaysShow: true,
    children: [
      {
        path: 'classmate/index',
        component: () => import('@/views/class/classmate/index'),
        hidden: true,
        name: 'ClassListPage',
        meta: { title: '班级维护', noCache: true }
      },
      {
        path: 'classmate/edit',
        component: () => import('@/views/class/classmate/edit'),
        hidden: true,
        name: 'ClassListEdit',
        meta: { title: '班级编辑', noCache: true, activeMenu: '/class/classmate/index' },
        hidden: true
      }/*,
      {
        path: 'student/list',
        component: () => import('@/views/class/student/list'),
        name: 'StudentListPage',
        meta: { title: '学生列表', noCache: true }
      },
      {
        path: 'student/edit',
        component: () => import('@/views/class/student/edit'),
        name: 'StudentEditPage',
        meta: { title: '学生编辑', noCache: true, activeMenu: '/class/student/list' },
        hidden: true
      },
      {
        path: 'student/edits',
        component: () => import('@/views/class/student/edits'),
        name: 'StudentEditsPage',
        meta: { title: '批量添加学生', noCache: true, activeMenu: '/class/student/list' },
        hidden: true
      },
      {
        path: 'grade/list',
        component: () => import('@/views/class/grade/list'),
        name: 'GradeListPage',
        meta: { title: '学生成绩', noCache: true }
      },

      {
        path: 'grade/search',
        component: () => import('@/views/class/grade/search'),
        name: 'StudentEditsPage',
        meta: { title: '个人成绩查询', noCache: true, activeMenu: '/class/grade/list' },
        hidden: true
      },
      {
        path: 'grade/all',
        component: () => import('@/views/class/grade/all'),
        name: 'StudentAllPage',
        meta: { title: '班级成绩详情', noCache: true, activeMenu: '/class/grade/list' },
        hidden: true
      }*/
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
        name: 'Profile',
        meta: { title: '个人中心', icon: 'user' }
      }
      // {
      //   path: 'index',
      //   component: () => import('@/views/system/user/index'),
      //   name: 'UserAdminPageList',
      //   meta: { title: '用户列表', noCache: true }
      // },
      // {
      //   path: 'edit',
      //   component: () => import('@/views/system/user/edit'),
      //   name: 'UserAdminEdit',
      //   meta: { title: '用户编辑', noCache: true, activeMenu: '/system/user/index' },
      //   hidden: true
      // }
    ]
  },
  {
    path: '/system',
    component: Layout,
    hidden: true,
    name: 'SystemPage',
    meta: {
      title: '用户管理',
      icon: 'tree'
    },
    children: [
      {
          path: 'user/index',
          component: () => import('@/views/system/user/index'),
          name: 'UserAdminPageList',
          meta: { title: '用户管理', noCache: true }
        },
        {
          path: 'user/edit',
          component: () => import('@/views/system/user/edit'),
          name: 'UserAdminEdit',
          meta: { title: '用户编辑', noCache: true, activeMenu: '/system/user/index' },
          hidden: true
        }
    ]
  },
  {
    path: '/category',
    component: Layout,
    hidden: true,
    name: 'CategoryPage',
    meta: {
      title: '类别管理',
      icon: 'tree'
    },
    children: [
      {
        path: 'course/index',
        component: () => import('@/views/category/course/index'),
        name: 'CategoryCoursePageList',
        meta: { title: '课程分类', noCache: true }
      },
      {
        path: 'course/edit',
        component: () => import('@/views/category/course/edit'),
        name: 'CategoryCourseEdit',
        meta: { title: '课程编辑', noCache: true, activeMenu: '/category/course/index' },
        hidden: true
      },
      {
        path: 'project/index',
        component: () => import('@/views/category/project/index'),
        name: 'CategoryProjectPageList',
        meta: { title: '项目分类', noCache: true }
      },
      {
        path: 'project/edit',
        component: () => import('@/views/category/project/edit'),
        name: 'CategoryProjectEdit',
        meta: { title: '项目编辑', noCache: true, activeMenu: '/category/project/index' },
        hidden: true
      },
      {
        path: 'paper/index',
        component: () => import('@/views/category/paper/index'),
        name: 'CategoryPaperPageList',
        meta: { title: '试卷分类', noCache: true }
      },
      {
        path: 'paper/edit',
        component: () => import('@/views/category/paper/edit'),
        name: 'CategoryPaperEdit',
        meta: { title: '试卷编辑', noCache: true, activeMenu: '/category/paper/index' },
        hidden: true
      },
      {
        path: 'lecturetitle/index',
        hidden: true,
        component: () => import('@/views/category/lecturetitle/index'),
        name: 'CategoryLecturetitlePageList',
        meta: { title: '讲师职称分类', noCache: true }
      },
      {
        path: 'lecturetitle/edit',
        hidden: true,
        component: () => import('@/views/category/lecturetitle/edit'),
        name: 'CategoryLecturetitleEdit',
        meta: { title: '讲师职称编辑', noCache: true, activeMenu: '/category/lecturetitle/index' },
        hidden: true
      }
    ]
  },

  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'type/data/:dictId(\\d+)',
        component: (resolve) => require(['@/views/system/dict/data'], resolve),
        name: 'Data',
        meta: { title: '字典数据', icon: '' }
      }
    ]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'log',
        component: (resolve) => require(['@/views/monitor/job/log'], resolve),
        name: 'JobLog',
        meta: { title: '调度日志' }
      }
    ]
  },

  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
        name: 'GenEdit',
        meta: { title: '修改生成配置' }
      }
    ]
  }
]

export default new Router({
  //mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
